clear 

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear

** Robustness regression dropping migrants, 1945-1962 **

drop if ma1994a_durres!=97

** regressions ** 

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW2_migrant

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW2_migrant

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW2_migrant

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW2_migrant

** Output Table **

#delimit ; 
estout m_MOB_did_BW2_migrant
	   m_School_did_BW2_migrant
	   m_LIT_did_BW2_migrant
	   m_YRS_did_BW2_migrant
       using "${output}/tables/TableA13.tex",
       style(tex) 
       cells(b(star fmt(3)) se(par fmt(3))) 
	   	   varlabels(did_ANY "Difference in Differences, registration" did_edu_ANY "Difference in Differences, education"  Female "Female " Arabic "First Language Arabic ")
keep(did_ANY did_edu_ANY)
	   stats(controls
	   adminFE
             r2 
             N
			 ymean, fmt(0 0 2 0 3 %9.0gc %9.0gc)
             labels("\hline Controls"
			 "\hline Admin FE"
                   "\hline \(R^2\)" 
                  " \hline N"
				   "Dep. Var. Mean "))
       mlabels(,none) 
       numbers
       collabels(none) 
       starl(* 0.1 ** 0.05 *** 0.01)
	          prehead( 
           \begin{table}[H]
           \caption{Effect of Reforms and European Settlement on Registration and Compulsory Education,Excluding Migrants, 1945-1962}        
           \label{tab:DiD_migrant2}            
           \centering
           \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 
           \hline \hline             
		   & \multicolumn{1}{p{3cm}}{\centering Registration} 
		   & \multicolumn{1}{p{3cm}}{\centering Formal Schooling}   
		   & \multicolumn{1}{p{3cm}}{\centering Literacy, Arabic and French}   
		   & \multicolumn{1}{p{3cm}}{\centering Formal Schooling, Years}                    \\                  
       )
       posthead(\hline) 
       prefoot() 
       postfoot(
           \noalign{\smallskip} \hline \hline 
           \end{tabular}
           \medskip
           \begin{minipage}{.9\textwidth}
           \tiny \justify Notes: \( @starlegend \). 
           \\ Fixed Effects and Clustered Robust Standard Errors at Province.
           \end{minipage}        
       \end{table}
       )
       replace;
#delimit cr
